package com.demo.common.support.page;

/**
 * 分页返回实体对象,以此实体进行方法分页返回
 *
 * @author molong
 * @since 2024/5/24
 */
public class Page {
    public Page(long total, int currPage, int pageSize) {
        setTotal(total);
        setCurrPage(currPage);
        setPageSize(pageSize);
        setTotalPage((int) Math.ceil((double) getTotal() / (double) getPageSize()));
    }

    /**
     * 数据总数
     */
    private long total;

    /**
     * 当前页
     */
    private int currPage;

    /**
     * 分页大小
     */
    private int pageSize;

    /**
     * 数据分页总数
     */
    private int totalPage;

    /**
     * 返回数据库分页总条数
     *
     * @return 分页总条数
     */
    public long getTotal() {
        return total;
    }

    /**
     * 返回当前分页值
     *
     * @return 当前分页
     */
    public int getCurrPage() {
        return currPage;
    }

    /**
     * 返回分页值大小
     *
     * @return 分页值
     */
    public int getPageSize() {
        return pageSize;
    }

    /**
     * 返回总分页数
     *
     * @return 总分页数
     */
    public int getTotalPage() {
        return totalPage;
    }


    public void setTotal(long total) {
        this.total = total;
    }


    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }


    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

}

